Contract
object for an already deployed contract is rather straightforward.
CallFunction
method to create a CallContractFunction
object which will determine the appropriate gasPrice, gasLimit, nonce, and data to include in a newly assembled EthTransaction
when provided with a client and a ContractCall
object to the Create
async Task
An example of calling a smart contract would look like:
SendTransactionMethod
instead.
Alternatively, if you want to simply create the EthTransaction
and send it at a later time, you can use the CallContractFunction
object from CallFunction
directly.
CallFunction
method accepts an arbitrary number of arguments. You’ll want to provide the arguments in the order they are provided in the ABI/function signature.
string
type or create an instance of Address
. Ensure that your string is a hexadecimal
string starting with 0x
and a fixed length of 42 characters.
int256
, uint8
, or uint256
you use the BigInteger
type from System.Numerics.
FixedByte
for types such as byte16
or byte32
.
When your contract requires bytes
you can convert any value into a byte[]
of any length.
If your data is represented as a hex string in C#, make sure to use our HexStringToByteArray()
function to convert
the hex value back to the original byte array.
For byte arrays such as byte32[]
, you simply create a FixedByte[]
in C#.
Contract.CallFunction
function.
Solidity Struct
string
or bool
, you can use the same data types in C#.
SendQuery<T>
method to query the contract and return the result as type T (if possible).
An example of querying a smart contract would look like:
QueryContract<T>
to create a delegate.
ContractDeployer